package com.infore.airsupervise.ui.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.TextView;

import com.beardedhen.androidbootstrap.AwesomeTextView;
import com.beardedhen.androidbootstrap.font.FontAwesome;
import com.infore.airsupervise.R;
import com.infore.airsupervise.adapter.ChartGridViewAdapter;
import com.infore.airsupervise.bean.MenuE;
import com.infore.airsupervise.other.listener.MainFragBtnClickListener;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 统计 Fragment
 */
public class StatisticsFragment extends BaseFragment {

    @BindView(R.id.titlebar_left_menu)
    AwesomeTextView titlebarLeftMenu;
    @BindView(R.id.titlebar_title)
    TextView titlebarTitle;
    @BindView(R.id.titlebar_right_menu)
    AwesomeTextView titlebarRightMenu;
    @BindView(R.id.statistics_grid_view)
    GridView statisticsGridView;

    private MainFragBtnClickListener listener;


    public StatisticsFragment() {
        // Required empty public constructor
    }

    @SuppressLint("ValidFragment")
    public StatisticsFragment(MainFragBtnClickListener listener) {
        this.listener = listener;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_statistics, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        titlebarLeftMenu.setFontAwesomeIcon(FontAwesome.FA_USER);
        titlebarTitle.setText("统计");
        titlebarRightMenu.setVisibility(View.INVISIBLE);

        ChartGridViewAdapter gridViewAdapter
                = new ChartGridViewAdapter(getContext(), MenuE.getChartMenuList());
        statisticsGridView.setAdapter(gridViewAdapter);
    }

    /**
     * 展示抽屉布局
     */
    @OnClick(R.id.titlebar_left_menu)
    void leftMenuClick() {
        if (listener != null) {
            listener.onShowDrawerBtnClick();
        }
    }

}
